/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DSB.Model.Kaart;

import java.awt.image.BufferedImage;

/**
 *
 * @author Gebruiker
 */
public abstract class Map {
    /**
     *
     */
    protected BufferedImage _map;
    /**
     *
     */
    protected static Coordinaat _upper_left;
    /**
     *
     */
    protected static Coordinaat _upper_right;
    /**
     *
     */
    protected static Coordinaat _lower_left;
    /**
     *
     */
    protected static Coordinaat _lower_right; 
    
    /**
     *
     */
    protected static int _width;
    /**
     *
     */
    protected static int _height;
    
    
    /**
     *
     */
    protected String _region;
    /**
     *
     */
    protected String _route;
    
    /**
     *
     * @return
     */
    public abstract BufferedImage DrawOnMap();

    
    /**
     *
     * @param coordinate
     * @param direction
     * @return
     */
    protected int ConvertCoordinate(double coordinate, Enums.CoordinateDirection direction)
    {
       
        double result;
        
        if(direction == Enums.CoordinateDirection.HORIZONTAL)
        {
            double rightLong = _upper_right.getLongitude();
            double leftLong = _upper_left.getLongitude();
            double mapdiff = rightLong - leftLong;
            double diffperpx = (mapdiff * 1000) / (_width * 1000);
            
            double mapcoord = _upper_left.getLongitude();
            double coorddiff = coordinate - mapcoord;
            result = (coorddiff * 1000000) / (diffperpx * 1000000);
            
        }
        else
        {
            double mapdiff = _lower_left.getLatitude() - _upper_left.getLatitude();
            double diffperpx = (mapdiff * 1000) / (_height * 1000);
            
            double mapcoord = _upper_left.getLatitude();
            double coorddiff = coordinate - mapcoord;
            result = (coorddiff * 1000000) / (diffperpx * 1000000);
        }
        
        return (int) Math.round(result);
    }
}
